package text;

import java.util.ArrayList;
import java.util.Scanner;

public class text6 {
    public static void main(String[] args) {
        ArrayList<User> list = new ArrayList<>();
        User u1 = new User("TWF1","zhangsan", "123456");
        User u2 = new User("TWF2","lisi", "12345678");
        User u3 = new User("TWF3","wangwu", "1234qwer");
        list.add(u1);
        list.add(u2);
        list.add(u3);

        System.out.println("请输入要查找的id");
        Scanner sc = new Scanner(System.in);
        String id = sc.next();

        boolean result = contains(list, id);

        System.out.println(result);

    }
    public  static boolean contains(ArrayList<User> list, String id) {
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getId().equals(id)) {
                return true;
            }
        }
        return false;
    }
}
